//
//  CellViewControllerForLabelAndSwitch.m
//  MemoryTasks
//
//  Created by Philippe Bouamriou on 15/05/10.
//  Copyright 2010 Philippe Bouamriou. All rights reserved.
//

#import "CellViewControllerForLabelAndSwitch.h"
#import "CellViewControllerForLabelAndSwitch-IB.h"


@implementation CellViewControllerForLabelAndSwitch

@synthesize _label, _switch, switchOn, labelText, childViewCells, linkedCell, delegate;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
   _label.text = labelText;
   _switch.on = switchOn;
   [super viewDidLoad];
}

- (void)didReceiveMemoryWarning {
   // Releases the view if it doesn't have a superview.
   [super didReceiveMemoryWarning];
   
   // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
   [super viewDidUnload];
   // Release any retained subviews of the main view.
   // e.g. self.myOutlet = nil;
   self._switch = nil;
   self._label = nil;
}



#pragma mark -
#pragma mark Mutators

- (void)setSwitchOn:(BOOL)isSwitchOn {
   _switch.on = isSwitchOn;
   switchOn = isSwitchOn;
}

- (void)setLabelText:(NSString *)theLabelText {
   if( theLabelText != labelText) {
      labelText = theLabelText;
      _label.text = labelText;
   }
}

#pragma mark -
#pragma mark Actions


-(IBAction)switchStateChanged:(id)sender {
   UISwitch *theSwitch = sender;
   if ([delegate respondsToSelector:@selector(cellViewController:switchStateChanged:)]) {
      [delegate cellViewController:self switchStateChanged:theSwitch];
   }
}

@end
